﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 读取西门子PLC_Demo
{
    public class VarableSiemens
    {
        /// <summary>
        /// 数据类型
        /// </summary>
        public DataTypeEnum DataType { get; set; } = DataTypeEnum.Byte;

        /// <summary>
        /// 西门子存储区
        /// </summary>
        public SiemensStore SiemensStore { get; set; } = SiemensStore.DB;

        /// <summary>
        /// 站号
        /// </summary>
        public ushort DBNum { get; set; } = 1;

        /// <summary>
        ///
        /// </summary>
        public int StartByteAddress { get; set; }

        /// <summary>
        ///
        /// </summary>
        public int BitOffset { get; set; }

        private object _value = 0;

        public object Value
        {
            get { return _value; }
            set
            {
                _value = value;
            }
        }
    }

    /// <summary>
    /// 西门子存储区,西门子官方手册上有这个代码的介绍
    /// </summary>
    public enum SiemensStore : byte
    {
        /// <summary>
        /// DB区,数据存储区
        /// </summary>
        DB = 0x84,//=132

        /// <summary>
        /// M区,内部继电器
        /// </summary>
        M = 0x83,//=131

        /// <summary>
        /// 输入线圈
        /// </summary>
        I = 0x81,//=129

        /// <summary>
        /// 输出线圈
        /// </summary>
        Q = 0x82,//=130

        /// <summary>
        ///计时器
        /// </summary>
        T = 0x1D,//=29,

        /// <summary>
        /// 计数器
        /// </summary>
        C = 0x1C//=28
    }
}